﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using Database.Classes;


public partial class StoredProcedures
{
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void InsertBattle(int aID, int aCV, int dID, int dCV, DateTime time, int sId, int pId, int wID)
    {
        using (SqlConnection conn = new SqlConnection(StaticMethods.ConnectionString()))
        {
            conn.Open();
            using (SqlCommand cmd = new SqlCommand("Insert Into Battles Values ( @aId, @dId, @aCV, @dCV, @d, @sId, @pId, @wId)", conn))
            {
                cmd.Parameters.Add("@aId", SqlDbType.Int).Value = aID;
                cmd.Parameters.Add("@dId", SqlDbType.Int).Value = dID;
                cmd.Parameters.Add("@aCV", SqlDbType.Int).Value = aCV;
                cmd.Parameters.Add("@dCV", SqlDbType.Int).Value = dCV;
                cmd.Parameters.Add("@d", SqlDbType.DateTime).Value = time;
                cmd.Parameters.Add("@sId", SqlDbType.Int).Value = sId;
                cmd.Parameters.Add("@pId", SqlDbType.Int).Value = pId;
                cmd.Parameters.Add("@wId", SqlDbType.Int).Value = wID;
                cmd.ExecuteNonQuery();
            }
        }
    }
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void InsertNews(int pid, DateTime t, string text)
    {
        using (SqlConnection conn = new SqlConnection(StaticMethods.ConnectionString()))
        {
            conn.Open();
            using (SqlCommand cmd = new SqlCommand("Insert Into News Values ( @s, @d, @t)", conn))
            {
                cmd.Parameters.Add("@s", SqlDbType.Int).Value = pid;
                cmd.Parameters.Add("@d", SqlDbType.DateTime).Value = t;
                cmd.Parameters.Add("@t", SqlDbType.NVarChar).Value = text;

                cmd.ExecuteNonQuery();
            }
        }
    }
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void InsertLog(DateTime t, string function, string text)
    {
        using (SqlConnection conn = new SqlConnection(StaticMethods.ConnectionString()))
        {
            conn.Open();
            using (SqlCommand cmd = new SqlCommand("Insert Into Logs Values ( @s, @d, @t)", conn))
            {
                cmd.Parameters.Add("@s", SqlDbType.DateTime).Value = t;
                cmd.Parameters.Add("@d", SqlDbType.NVarChar).Value = function;
                cmd.Parameters.Add("@t", SqlDbType.NVarChar).Value = text;

                cmd.ExecuteNonQuery();
            }
        }
    }
};
